<template>
  <div class="container">
    <div style="padding-left: 10px">
      <el-row class="Jcommon-search-box" :gutter="16">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

		  <el-form-item label="开始时间" prop="beginDate">
            <el-date-picker clearable
              v-model="feeParams.beginTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择开始时间">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="结束时间" prop="endDate">
            <el-date-picker clearable
              v-model="feeParams.endTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="请选择结束时间">
            </el-date-picker>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="getData()">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </el-row>
<!-- -->
      <div>
        <div>
          <el-form>
            <el-row>
              <el-col :span="4">
                <el-form-item label="实收金额" style="margin-bottom: 0px">
                  <label style="color: #1890ff">
                    <!--                    {{ data.paySum.receivable }}-->
                    <!-- 2222222222 -->
					{{totalFee}}
                  </label>
                </el-form-item>
              </el-col>

              <el-col :span="4">
                <el-form-item label="滞纳金" style="margin-bottom: 0px">
                  <label style="color: #1890ff">
                    <!--                    {{ data.paySum.lateFeeMoney }}-->
                    11350
                  </label>
                </el-form-item>
              </el-col>

              <el-col :span="4">
                <el-form-item label="优惠金额" style="margin-bottom: 0px">
                  <label style="color: #1890ff">
                    <!--                    {{ data.paySum.discount }}-->
                    1150
                  </label>
                </el-form-item>
              </el-col>
            </el-row>

            <!--            2-->
            <el-row :gutter="16" :style="'width:100%'">
              <el-col :span="4">
                <el-form-item label="收款金额" style="margin-bottom: 0px">
                  <label style="color: #1890ff">
					{{totalRefund+totalFee}}
                    <!--                    {{ data.paySum.payMoney }}-->
                    <!-- 22555 -->
                  </label>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item label="预存款支付" style="margin-bottom: 0px">
                  <label style="color: #1890ff">
                    <!--                    {{ data.paySum.prePayMoney }}-->
                    226660
                  </label>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="找零结存" style="margin-bottom: 0px">
                  <label style="color: #1890ff">20
                  </label>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>

        <!--表格1-->
      <!--  <div>
          <div style="padding-left: 10px">
            <el-tabs  style="height: 100%">
              <el-tab-pane label="常规收费合计" name="first"></el-tab-pane>
            </el-tabs>
          </div>

          <div>
            <el-table  max-height="500px" style="width: 600px">
              <el-table-column prop="resourceName" label="商铺编号" align="left" width="150px" />
              <el-table-column prop="lateFee" label="滞纳金" align="left" width="150px" />
              <el-table-column prop="discount" label="优惠金额" align="left" width="150px" />
              <el-table-column prop="total" label="实收金额" align="left" width="150px" />
            </el-table>
          </div>
        </div -->
        <!--表格2-->
        <div>
          <div style="padding-left: 10px">

            <el-tabs  style="height: 100%">
              <el-tab-pane label="押金收费合计" name="first"></el-tab-pane>
            </el-tabs>
          </div>
          <div>

            <el-table :data="feeList">
              <el-table-column prop="shopCode" label="商铺编号" align="left" width="150px" />
              <el-table-column prop="getMoney" label="实收金额" align="left" width="150px" />
            </el-table>
          </div>
        </div>
        <!--        表格3-->
        <div>
          <div style="padding-left: 10px">
            <el-tabs  style="height: 100%">
              <el-tab-pane label="临时收费合计" name="first"></el-tab-pane>
            </el-tabs>
          </div>
          <div>
            <el-table :data="feeList">
              <el-table-column prop="shopCode" label="商铺编号" align="left" width="150px" />
              <el-table-column prop="getMoney" label="实收金额" align="left" width="150px" />
            </el-table>
          </div>
        </div>

        <!--        退费表-->
        <h1 style="margin-top: 50px; padding-left: 10px">退费合计</h1>
        <div class="Jcommon-head">
          <el-form @submit.native.prevent size="mini" :style="'width:100%'">
            <el-row :gutter="16" :style="'width:100%'">
              <el-col :span="4">
                <el-form-item label="退还金额" style="margin-bottom: 0px">
                  <label style="color: #1890ff">
					 {{totalRefund}}
                  </label>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
        <!--        表4-->
        <div>
          <div style="padding-left: 10px">
            <el-tabs  style="height: 100%">
              <el-tab-pane label="押金退还合计" name="first"></el-tab-pane>
            </el-tabs>
          </div>
          <div>
            <!--           :data="data.depositRefundSum" -->
            <el-table :data="refundList">
              <el-table-column prop="shopCode" label="商铺编号" align="left" width="150px" />
              <el-table-column prop="getMoney" label="退还金额" align="left" width="150px" />
            </el-table>
          </div>
        </div>

        <!--        表5-->
        <div>
          <div style="padding-left: 10px">
            <!--            v-model="activeName" @tab-click="handleClick"-->
            <el-tabs  style="height: 100%">
              <el-tab-pane label="临时收费退还合计" name="first"></el-tab-pane>
            </el-tabs>
          </div>
          <div>
            <el-table :data="refundList">
              <el-table-column prop="shopCode" label="商铺编号" align="left" width="150px" />
              <el-table-column prop="getMoney" label="退还金额" align="left" width="150px" />
            </el-table>
          </div>
        </div>

      </div>
    </div>
  </div>



</template>

<script>
import { listPaymentbillhouse, getPaymentbillhouse, delPaymentbillhouse, addPaymentbillhouse, updatePaymentbillhouse } from "@/api/system/paymentbill";
import request from '@/utils/request';
import {listSftjhouse} from '@/api/system/sftjhouse'
export default {
  name: "housebillhouse",
  data() {
    return {
		//退费列表
		refundList:[],
		//收费列表
		feeList:[],
		// 退款参数
		refundParams:{
			beginTime:null,
			endTime:null,
			adState:1,
			tdState:1
		},
		//总费
		totalFee:null,
		//总退费
		totalRefund:null,
		//收费查询参数
		feeParams:{
			beginTime:null,
			endTime:null,
			adState:0,
			tdState:0
		},
		//获取接口数据，，，，
	  data:{},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 收费统计1表格数据
      paymentbillList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        beginDate: null,
        endDate: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {

      }
    };
  },
  created() {
 //    this.getList();
	// this.getData();
  },
  methods: {
	  // 退费查询列表
	  getRefundList(){
		  this.loading=true;
		  this.refundParams.beginTime=this.feeParams.beginTime
		  this.refundParams.endTime=this.feeParams.endTime;
		  listSftjhouse(this.refundParams).then(res=>{
		  	this.refundList=res.rows
			for(let item of this.refundList){
				this.totalRefund += item.getMoney+item.amtMoney
			}
		  	this.loading=false;
		  })
	  },
    /** 查询收费统计1列表 */
	getData(){
		this.loading=true;
		listSftjhouse(this.feeParams).then(res=>{
			this.feeList=res.rows
			for(let item  of this.feeList){
				this.totalFee += item.getMoney+item.amtMoney
			}
			this.loading=false;
			this.getRefundList();
		})
	},
    getList() {
      this.loading = true;
      listPaymentbillhouse(this.queryParams).then(response => {
        this.paymentbillList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },



    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加收费统计1";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getPaymentbill(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改收费统计1";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updatePaymentbill(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPaymentbill(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除收费统计1编号为"' + ids + '"的数据项？').then(function() {
        return delPaymentbill(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/paymentbillhouse/export', {
        ...this.queryParams
      }, `paymentbill_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>


